﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.Reporting.WebForms;
using Catering.View_Operaction;
using System.Data;

namespace Catering.Catering_Page.ShanShiFenXi
{
    public partial class PersonType_Sum : System.Web.UI.Page
    {
        // 属性注入
        private static View_Monitor vm = new View_Monitor();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }
        }

        protected void lbtn_Click(object sender, EventArgs e)
        {
            string AREAID = DDLTool1.GetDDL_Area();
            string CLASSID = DDLTool1.GetDDL_Class();
            string Year = DDLTool1.GetYear();
            if (string.IsNullOrEmpty(Year))
            {
                return;
            }
            DateTime DTIME = DateTime.Parse("1949-10-01 00:00:11");
            DateTime.TryParse(Year + "-01-01 00:00:11",out DTIME);
            string TITLE = Bind_Data_to_Controls.Bind_ReportTitle(AREAID, CLASSID, DTIME, "人均消耗分类汇总");
            string pid = "0";
            if (Session["UserID"] != null) pid = Session["UserID"].ToString();
            DataTable dt = vm.GetPersonAvgXiaohaoType(pid,AREAID, CLASSID, DTIME, TITLE);
            // 报表的数据源
            ReportDataSource rds = new ReportDataSource("DataSet1", dt);

            // 先清除报表数据源
            ReportViewer1.LocalReport.DataSources.Clear();

            // 绑定数据源
            ReportViewer1.LocalReport.DataSources.Add(rds);

            // 呈现出数据
            ReportViewer1.LocalReport.Refresh();
            ReportViewer1.Visible = true;
        }
    }
}